library(tidyverse)
library(data.table)
library(ggh4x)
data loading
files <- dir("exp1_data_eyetracking_individual_saccades", ".*csv$", full.names = TRUE)
dat <- c()
for (i in 1:length(files)) {
d <- fread(files[i], header = TRUE)
d$id <- i # numeric variable for subject id
dat <- rbind(dat, d)
d <- subset(d, d$event == "fixation")
d <- mutate(d, target = apply(d, 1, function(x){names(d)[13 + which.max(x[14:16])]}))
d <- mutate(d, dud = apply(d, 1, function(x){names(d)[13 + which.min(x[14:16])]}))
p <- ggplot(d) + geom_point(aes(x = x, y = y, size = dur, color = factor(Condition)), alpha = 0.3) +
facet_nested(. ~ target + dud) + ggtitle(i)
print(p)
}









